import { intersection, chain, each } from 'lodash'

export function setWarningNodes(
  topoRef: any,
  warningIps: string[],
  nodeBusinessData: any[]
) {
  const currentIps = chain(nodeBusinessData).map('ip').value()
  each(currentIps, ip => {
    topoRef.value.setNodeStatus(ip, 'normal')
  })
  intersection(warningIps, currentIps).forEach(ip => {
    topoRef.value.setNodeStatus(ip, 'warning')
  })
}
